package com.bristua.mall.common.biz;

import com.bristua.mall.common.dao.TDictionaryMapper;
import com.bristua.mall.common.model.TDictionary;
import com.bristua.mall.common.model.condition.TDictionaryExample;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2019/4/27.
 */
@Service
public class QueryDictionaryBiz {

    @Resource
    private TDictionaryMapper tDictionaryMapper;

    public List<TDictionary> queryDictionary(String key){
        TDictionaryExample tDictionaryExample = new TDictionaryExample();
        tDictionaryExample.createCriteria().andDictionaryKeyEqualTo(key);
        return tDictionaryMapper.selectByExample(tDictionaryExample);
    }

    public void updateDictionary(TDictionary tDictionary){
        if(tDictionary!=null && StringUtils.isEmpty(tDictionary.getDictionaryId())){
            tDictionaryMapper.updateByPrimaryKeySelective(tDictionary);
        }
    }

}
